package com;

import com.dao.UserDao;
import com.pojo.User;
import com.service.UserService;
import com.sun.glass.ui.Application;

@Configuration // 说明当前类是配置类 作用类似 applicationContext.xml
@ConponentScan // 扫描项目中的所有bean类（添加了@Component）
@EnableAspectJAutoProxy
public class AppCongig {
    public static <ApplicationContext> void main(String[] args) {
        ApplicationContext context = new AnnotationfigApplicationContext(AppConfig.class);
        User user = context.getBean(User.class);
        // 上两行作用等同于User user=new User();
        System.out.println(user);
        UserService userService = context.getBean(UserService.class);
        boolean flag = userService.login("张三","123");
        if (flag) {
            System.out.println("登录成功");
        }else {
            System.out.println("登录失败");
        }
        UserDao userDao = context.getBean(UserDao.class);
        userDao.update();
        userDao.insert();
        userDao.delete();
        userDao.select();
    }
}
